package com.uking.helper;

import com.uking.util.Utils;
import com.uking.util.VKConstant;
import com.uking.util.VKUmengCollection;
import com.uking.util.VKUmengCollection.ErrorKeyCode;

public class VKErrorMessageUtil {
    public static void setMessageInfo(int errorCode, String errorMsg) {
        VKErrorMessage errormsg = VKErrorMessage.getInstace();
        errormsg.clearMessage();
        errormsg.setMessage(errorCode, errorMsg);
    }

    public static void setMessageInfo(int errorCode) {
        VKErrorMessage errormsg = VKErrorMessage.getInstace();
        errormsg.clearMessage();
        errormsg.setErrorCode(errorCode);
    }

    public static int getErrorCode() {
        return VKErrorMessage.getInstace().getErrorCode();
    }

    public static String getErrorMsage() {
        return VKErrorMessage.getInstace().getErrorMsg();
    }

    public static void setEmptyErrorMsage() {
        VKErrorMessage.getInstace().clearMessage();
    }

    public static boolean saveErrorMsge(String response, String sn) {
        int encryptArr = 0;
        String encryptmsg = "unkown";
        String[] arrResponse = response.split(" ");
        if (arrResponse != null && arrResponse.length > 0) {
            String[] arrContent = arrResponse[0].split("=");
            if (arrContent != null && arrContent.length > 1) {
                if (arrContent[1] == null) {
                    arrContent[1] = "";
                }
                encryptArr = Integer.valueOf(arrContent[1]).intValue();
            }
            if (arrResponse.length >= 2 && arrResponse[1] != null) {
                encryptmsg = arrResponse[1];
            }
        }
        VKLogger.d("ErrorMessageUtil", "error code = " + encryptArr);
        VKLogger.d("ErrorMessageUtil", "error msg = " + encryptmsg);
        setMessageInfo(encryptArr, encryptmsg);
        return checkErrorMsge(encryptArr, sn);
    }

    public static boolean saveMianErrorMsge(String response, String sn) {
        int encryptArr = 0;
        String encryptmsg = "unkown";
        String[] arrResponse = response.split(" ");
        if (arrResponse != null && arrResponse.length > 0) {
            String[] arrContent = arrResponse[0].split("=");
            if (arrContent != null && arrContent.length > 1) {
                if (arrContent[1] == null) {
                    arrContent[1] = "";
                }
                encryptArr = Integer.valueOf(arrContent[1]).intValue();
            }
            if (arrResponse.length >= 2 && arrResponse[1] != null) {
                encryptmsg = arrResponse[1];
            }
        }
        boolean notExist = checkMainErrorMsge(encryptArr, sn);
        if (!notExist) {
            setMessageInfo(encryptArr, encryptmsg);
        }
        Utils.log("saveMainErrorMsge error code = " + encryptArr);
        Utils.log("saveMainErrorMsge error msg = " + encryptmsg);
        return notExist;
    }

    private static boolean checkMainErrorMsge(int error, String sn) {
        switch (error) {
            case 20000/*20000*/:
                VKUmengCollection.CollectionErrInfoMsg(null, sn, ErrorKeyCode.ERCODE_EA1);
                return false;
            case VKConstant.AAA_EPG4B_TIMEOUT_ERROR /*20200*/:
                return false;
            case VKConstant.EPG4B_NOPRODUCT_ERROR /*20300*/:
                VKUmengCollection.CollectionErrInfoMsg(null, sn, ErrorKeyCode.ERCODE_EA5);
                return false;
            case VKConstant.ZHONGJIANJIAN_LOW_ERROR /*20400*/:
                return false;
            case VKConstant.ZHONGJIANJIAN_DATA_ERROR /*20500*/:
                VKUmengCollection.CollectionErrInfoMsg(null, sn, ErrorKeyCode.ERCODE_EA7);
                return false;
            case 21800 /*21800*/:
                return false;
            case 21900/*21900*/:
                VKUmengCollection.CollectionErrInfoMsg(null, sn, ErrorKeyCode.ERCODE_ED2);
                return false;
            case 22000 /*22000*/:
                return false;
            case VKConstant.LICENSE_EXPIRED /*23000*/:
                VKUmengCollection.CollectionErrInfoMsg(null, sn, ErrorKeyCode.ERCODE_EA8);
                return false;
            case VKConstant.NOT_USE_IN_BUY_PLACE /*24000*/:
                VKUmengCollection.CollectionErrInfoMsg(null, sn, ErrorKeyCode.ERCODE_EA9);
                return false;
            default:
                return true;
        }
    }

    public static boolean checkErrorMsge(int error) {
        boolean notExist = false;
        switch (error) {
            case VKConstant.AAA_EPG4B_TIMEOUT_ERROR /*20200*/:
                notExist = true;
                break;
            case VKConstant.EPG4B_NOPRODUCT_ERROR /*20300*/:
                notExist = true;
                break;
            case VKConstant.ZHONGJIANJIAN_LOW_ERROR /*20400*/:
                notExist = true;
                break;
        }
        Utils.log("\u4e3bAAA\u6ce8\u518c\u5931\u8d25\uff0c\u68c0\u67e5\u9519\u8bef\u7801\u662f\u5426\u53ef\u4ee5\u7528\u7f13\u5b58\uff0ccheckErrorMsge=" + error + "notExist=" + notExist);
        return notExist;
    }

    private static boolean checkErrorMsge(int error, String sn) {
        switch (error) {
            case 20000 /*20000*/:
                VKUmengCollection.CollectionErrInfoMsg(null, sn, ErrorKeyCode.ERCODE_EA1);
                return false;
            case VKConstant.EPG4B_NOPRODUCT_ERROR /*20300*/:
                VKUmengCollection.CollectionErrInfoMsg(null, sn, ErrorKeyCode.ERCODE_EA5);
                return true;
            case VKConstant.ZHONGJIANJIAN_DATA_ERROR /*20500*/:
                VKUmengCollection.CollectionErrInfoMsg(null, sn, ErrorKeyCode.ERCODE_EA7);
                return false;
            case 21800 /*21800*/:
                return false;
            case 21900 /*21900*/:
                VKUmengCollection.CollectionErrInfoMsg(null, sn, ErrorKeyCode.ERCODE_ED2);
                return false;
            case 22000 /*22000*/:
                return false;
            case VKConstant.LICENSE_EXPIRED /*23000*/:
                VKUmengCollection.CollectionErrInfoMsg(null, sn, ErrorKeyCode.ERCODE_EA8);
                return false;
            case VKConstant.NOT_USE_IN_BUY_PLACE /*24000*/:
                VKUmengCollection.CollectionErrInfoMsg(null, sn, ErrorKeyCode.ERCODE_EA9);
                return false;
            default:
                return true;
        }
    }
}
